<?php

namespace app\admin\middleware\common;

use app\admin\service\common\AuthCheckService;
use app\common\facade\Principal;
use think\facade\Log;
use think\facade\App;

class CheckPermission
{
    public function handle($request, \Closure $next)
    {
        $controller = $request->controller();
        $action = $request->action();

        // 权限检查
        if (Principal::hasLogin()) {
            AuthCheckService::check($controller, $action, Principal::getPerms());
        }

        return $next($request);
    }
}